package io.mft.plugin;

import cn.hutool.core.util.ObjectUtil;
import io.mft.commons.ioc.BeanBeforeInitialization;
import io.mft.commons.ioc.BeanBeforeInitializationProcessor;
@BeanBeforeInitialization
public class PluginFunctionBeanBeforeInitializationProcessor extends BeanBeforeInitializationProcessor<PluginFunction<?>> {

	@Override
	public boolean isConditionClass(Class<?> classType) {
		PAFunction function = classType.getDeclaredAnnotation(PAFunction.class);
		return ObjectUtil.isNotNull(function);
	}

	@Override
	protected void process(PluginFunction<?> bean, String beanId) {
		PAFunction function = bean.getClass().getDeclaredAnnotation(PAFunction.class);
		PluginFunctionAttribute pluginFunctionAttribute = new PluginFunctionAttribute();
		pluginFunctionAttribute.setDesc(function.note());
		pluginFunctionAttribute.setId(function.value());
		bean.setPluginFunctionAttribute(pluginFunctionAttribute);
	}

	

}
